/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-09-19
 * Time:19:42
 */
import java.util.*;
public class Main {

    public void check(List<Character> list) {
        if (list.size() <= 2) return ;
        int num = 1;
        for (int i = 0; i < list.size() - 1; i++) {
            if (list.get(i) == list.get(i + 1)) {
                num++;
                if (num == 3) {
                    int index = i - 1;
                    Character del = list.get(i);
                    while (list.size() > 0 && list.size() > index && list.get(index) == del) {
                        list.remove(index);
                    }
                    check(list);
                    break;
                }
            }else {
                num = 1;
            }
        }
    }

    public void print(List<Character> list) {
        if (list.size() == 0) {
            System.out.print("-");
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i));
        }
        System.out.println();
    }

    public static void main(String args[]) throws Exception
    {
        Main M = new Main();
        Scanner scanner = new Scanner(System.in);
        List<Character> list = new LinkedList<>();
        String s = scanner.nextLine();
        for (char c : s.toCharArray()) {
            list.add(c);
        }
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int index = scanner.nextInt();
            char c = scanner.next().charAt(0);
            list.add(index,c);
            M.check(list);
            M.print(list);
        }
    }
}
